<template>
    <div style="margin-top:30px;">
        <el-form ref="form" :rules="rules" :model="form" label-width="80px">
                            <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="uuid" prop="code"  style="margin-right:15px">
                                <el-input v-model="form.code" placeholder="请输入uuid" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="用户编码" prop="userCode"  style="margin-right:15px">
                                <el-input v-model="form.userCode" placeholder="请输入用户编码" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="订单编码" prop="orderCode"  style="margin-right:15px">
                                <el-input v-model="form.orderCode" placeholder="请输入订单编码" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="默认0在线支付，1现金支付" prop="paidLineType"  style="margin-right:15px">
                                <el-input v-model="form.paidLineType" placeholder="请输入默认0在线支付，1现金支付" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="消费项目：充值-0，北斗-1，短信-2，软件-3" prop="paidItem"  style="margin-right:15px">
                                <el-input v-model="form.paidItem" placeholder="请输入消费项目：充值-0，北斗-1，短信-2，软件-3" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="收入(0) or 支出(1)" prop="paidFeeType"  style="margin-right:15px">
                                <el-input v-model="form.paidFeeType" placeholder="请输入收入(0) or 支出(1)" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="变动金额" prop="paidAmount"  style="margin-right:15px">
                                <el-input v-model="form.paidAmount" placeholder="请输入变动金额" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="备注" prop="paidRemark"  style="margin-right:15px">
                                <el-input v-model="form.paidRemark" placeholder="请输入备注" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="平台账户余额" prop="accountAmount"  style="margin-right:15px">
                                <el-input v-model="form.accountAmount" placeholder="请输入平台账户余额" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple">
                            <el-form-item label="所属机构编码" prop="createByBranch"  style="margin-right:15px">
                                <el-input v-model="form.createByBranch" placeholder="请输入所属机构编码" />
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="funcCancel">取 消</el-button>
            <el-button type="primary" @click="funcSubmit">确 定</el-button>
        </div>
    </div>
</template>
<script>
    import Vue from 'vue'
    import 'xe-utils'
    import VXETable from 'vxe-table'
    import 'vxe-table/lib/index.css'
    import request from '@/utils/request'
    Vue.use(VXETable)
    export default {
        name: 'paidRecordEdit',
        data() {
            return {
                emptyForm:{},
                form: {
                    code: '',
                    userCode: '',
                    orderCode: '',
                    paidLineType: '',
                    paidItem: '',
                    paidFeeType: '',
                    paidAmount: '',
                    paidRemark: '',
                    accountAmount: '',
                    createByBranch: '',
                },
                rules: {
                    code: [
                        { required: true, message: '请输入uuid', trigger: 'blur' },
                        
                    ],
                    userCode: [
                        { required: true, message: '请输入用户编码', trigger: 'blur' },
                        
                    ],
                    orderCode: [
                        { required: true, message: '请输入订单编码', trigger: 'blur' },
                        
                    ],
                    paidLineType: [
                        { required: true, message: '请输入默认0在线支付，1现金支付', trigger: 'blur' },
                        
                    ],
                    paidItem: [
                        { required: true, message: '请输入消费项目：充值-0，北斗-1，短信-2，软件-3', trigger: 'blur' },
                        
                    ],
                    paidFeeType: [
                        { required: true, message: '请输入收入(0) or 支出(1)', trigger: 'blur' },
                        
                    ],
                    paidAmount: [
                        { required: true, message: '请输入变动金额', trigger: 'blur' },
                        
                    ],
                    paidRemark: [
                        { required: true, message: '请输入备注', trigger: 'blur' },
                        
                    ],
                    accountAmount: [
                        { required: true, message: '请输入平台账户余额', trigger: 'blur' },
                        
                    ],
                    createByBranch: [
                        { required: true, message: '请输入所属机构编码', trigger: 'blur' },
                        
                    ],
                }
            }
        },
        created() {
            //保存空表单对象
            this.emptyForm =JSON.parse(JSON.stringify(this.form))
        },
        methods: {
            // 获取页面信息
            getInfo(code) {
                //查询到数据之前先展示空表单
                this.form=JSON.parse(JSON.stringify(this.emptyForm))
                request({ url: `/arpa-basic-api/paidRecord/${code}`, method: 'get' }).then(response => {
                    this.form = response.data
                })
            },
            // 提交
            funcSubmit() {
                this.$refs['form'].validate((valid) => {
                    if (valid) {
                        const data = this.form
                        const rLoading = this.openLoading();
                        request({ url: '/arpa-basic-api/paidRecord', method: 'put', params: data }).then(response => {
                          rLoading.close();
                            this.$message({ message: response.msg, type: 'success' })
                            this.$emit('fatherEditMethod')
                        })
                    } else {
                        return false;
            }
            });
            },
            // 取消
            funcCancel() {
                this.$emit('fatherCancelMethod', 'edit')
            }

        }
    }
</script>
<style lang="scss" scoped>
    .dialog-footer {
        margin:15px 0 15px 0;
        width: 175px;
        float: right;
    }
</style>
